package entity.plane.impl;

import entity.plane.Plane;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.hibernate.validator.constraints.NotEmpty;

@Entity
@Table(name = "plane")
public class PlaneImpl implements Plane {

	private Long id;

	String model;

	Integer capacity;

	public PlaneImpl(String model, Integer capacity) {
		this.model = model;
		this.capacity = capacity;
	}

	@NotEmpty
	@Column(name = "model")
	public String getModel() {
		return model;
	}

	@Override
	public void setModel(String model) {
		this.model = model;
	}

	@NotEmpty
	@Column(name = "capacity")
	public Integer getCapacity() {
		return capacity;
	}

	@Override
	public void setCapacity(Integer capacity) {
		this.capacity = capacity;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "plane_id")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
}
